package jsyf.oa.web.report;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.RegionReportFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/2/7 0007.
 */

@Api(value = "客户拜访报表接口--大区", description = "客户拜访报表接口--大区")
@Controller
@RequestMapping("/reportRegion")
public class RegionReportController {

    @Resource
    private RegionReportFacade regionReportFacade;


    @RequestMapping(value = "/getByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "一级报表",
            notes = "一级报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{companyId:'2017121617464D12B1025EC2259267D2'}", dataType = "String", paramType = "body")
    })
    public void getUserByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.regionReportFacade.getByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getCompanyByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团管理层报表",
            notes = "集团管理层报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29'}", dataType = "String", paramType = "body")
    })
    public void getCompanyByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.regionReportFacade.getCompanyByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getRegionByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司管理层二级报表",
            notes = "公司管理层二级报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-01-29',companyId:'2017121617464D12B1025EC2259267D2'}", dataType = "String", paramType = "body")
    })
    public void getRegionByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.regionReportFacade.getRegionByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getCustomerByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "大区拜访客户报表",
            notes = "大区拜访客户报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'2018-02-06',userId:'2018010915264E0B9F9E22BEEABD4C6E',entourageId:'2017121620264ACD99471A6FCECBA0AC'}", dataType = "String", paramType = "body")
    })
    public void getCustomerByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.regionReportFacade.getCustomerByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }
}
